package com.zhangchenhui.powerMock;

public class EmployeeService {
    private EmployeeDao employeeDao;
    private FinalEmployeeDao finalEmployeeDao;
    public EmployeeService() {
    }
    public EmployeeService(EmployeeDao employeeDao) {
        this.employeeDao = employeeDao;
    }

    public EmployeeService(FinalEmployeeDao finalEmployeeDao) {
        this.finalEmployeeDao = finalEmployeeDao;
    }

    /**
     * 获取所有员工的数量.
     *
     * @return
     */
    public int getTotalEmployee() {
        return employeeDao.getTotal();
    }

    public void createFinalEmployee(Employee employee)
    {
        finalEmployeeDao.addEmployee(employee);
    }

    public void createEmployee(Employee employee)
    {
        employeeDao.addEmployee(employee);
    }

    public int getTotalEmployee2() {
        EmployeeDao employeeDao = new EmployeeDao();
        return employeeDao.getTotal();
    }

    public void createEmployee2(Employee employee)
    {
        EmployeeDao employeeDao = new EmployeeDao();
        employeeDao.addEmployee(employee);
    }

    public int getEmployeeCount3() {
        return EmployeeUtils.getEmployeeCount();
    }

    public void createEmployee3(Employee employee) {
        EmployeeUtils.persistenceEmployee(employee);
    }

    public void saveOrUpdate(Employee employee) {
        final EmployeeDao employeeDao = new EmployeeDao();
        long count = employeeDao.getCount(employee);
        if (count > 0)
            employeeDao.updateEmploye(employee);
        else
            employeeDao.saveEmployee(employee);
    }

    public String findEmailByUserName(String userName) {
        throw new UnsupportedOperationException();
    }

    public boolean exist(String userName) {
        checkExist(userName);
        return true;
    }
    private void checkExist(String userName) {
        throw new UnsupportedOperationException();
    }

}